package com.yanqu.road.server.cmd.activity.silkroad;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.SilkRoadProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.silkroad.SilkRoadModule;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_SILK_ROAD_LAUNCH_HOOK, desc = "发射鱼钩")
public class SilkRoadLaunchHookCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {

        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        SilkRoadProto.SilkRoadLaunchHookReqMsg reqMsg = SilkRoadProto.SilkRoadLaunchHookReqMsg.parseFrom(packet.getBytes());
        ret = player.getModule(SilkRoadModule.class).launchHook(reqMsg.getActivityId(), reqMsg.getScene(), reqMsg.getOneKey());
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0) {
            player.sendPacket(ClientProtocol.U_SILK_ROAD_LAUNCH_HOOK, SilkRoadProto.SilkRoadLaunchHookRespMsg.newBuilder().setRet(ret));
        }
    }
}
